﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;

namespace EnvironmentEditor.Resources
{
    public class ResourceManager
    {
        private List<TextureItem> sprites = new List<TextureItem>();

        public List<TextureItem> Sprites 
        {
            get { return this.sprites; } 
        }

        public void LoadTexture(string path, string name)
        {
            if (File.Exists(path) && !string.IsNullOrWhiteSpace(name) && !this.sprites.Any(x => x.Name == name))
            {
                var texture = new TextureItem();
                texture.Name = name;
                texture.Path = path;
                texture.Thumbnail = Image.FromFile(path);
                texture.MapSprite = Image.FromFile(path);
                texture.Id = (ushort)(Sprites.Count + 1);
                this.sprites.Add(texture);
            }
        }
    }
}
